Overview
Posts make up the blog part of the site. They serve to allow me to put up short bits about various topics. I sometimes use the posts to complain about things but I’ve been trying to stay away from that and focus on random topics of interest. Because the site is public I try to avoid sensitive subjects such as religion and politics that I could probably post about but I don’t want to take the chance of offending someone.
/post files
post_example.html
The posts are simple HTML files formatted to be read by several scripts on the site. All posts reside in the "posts" directory. There are two filename conventions used by posts. The first set of files is for normal posts and they are named “post<ID>.html” with ID being a 4 number string unique to that post. The second set of files is for top posts and they are named “top<ID>.html”. The two sets of files are formatted the same with the only difference being that top posts always get displayed on the front page while the number of normal posts that get displayed is limited. The first line of the file is the date it is posted in the format “MM/dd/yy” followed by a dash and the post’s title. The rest of the file contains the text of the post.
/post comment files
coment_example.xml
Along with the post files there are also comment files contained in the “posts” directory. These are xml files named “post<ID>.xml” with ID being a 4 number string identifying the post the comment file belongs to. The files are created the first time a post is commented on and they are displayed whenever a user looks at an individual post. The “comments” tag is the top most tag in the file. Within this tag is a series of “comment” tags which each contain a “name” and a “text” tag. The value of the “name” tag is the name the person gave when they posted the comment and the value of the “text” tag is the contents of the comment they posted.
post.html
This is the post template file. It is displayed as part of the individual post pages and contains the layout for the comments section. It mainly consists of the form to add comments to a post but also contains the markings for where the script should read and display comments previously added.
File not found: posts/post.php Post.php is the script to display a single post. It starts out by initializing the line variables and then it opens the appropriate post file. If the “top” parameter is set to true it opens the “top<ID>.html” file else it opens the “post<ID>.html” file, in either case ID is the value of the “post” parameter. It starts by opening the main template file and displaying each line. It sets the title to be of the form "Penguin Stew - Post - " + the post ID and the continues on. In the right section the script displays the title of the post (Which it gets from the first line of the file) as a centered heading and then displays the rest of the post file which is the test of the post. After it is finished displaying the post the script opens the post template file and starts displaying it. When the script gets to the line indicated by the “$comment” line variable it tries to open the corresponding “post<ID>.xml” file and if one exists the script parses it and displays any comments present. When the script gets to the line indicated by the “$commentInput” line variable it inserts a hidden input tag containing the post id. This is used by the script that’s run when the form is submitted to indicate which post to add the comment too. The script then fishes displaying the contents of both template files and then closes.
index.php
This is the main page of the site. It starts out by displaying all of the top posts and then displaying a number of the most recent normal posts. The number of normal posts displayed is determined by four minus the minimum of the number of top posts and two. This is done to prevent the front page from becoming cluttered if there are a lot of top posts but while ensuring some recent posts are still displayed. For both post types are displayed with the title above the entire post text with the title being a link to the individual post page. Top posts are separated from normal posts by being at the top of the page regardless of the post date. Top posts also have centered titles and solid lines above and below each post to make them stand out more.
File not found: archive.html The archive page contains a list of all posts organized by post type and date. The start of the page contains a list of top posts if there are any and then the normal posts. Both lists contain the list of posts titles linked to each individual post page separated into month name and year headings. The normal list is collapsed so that only the posts from the most recent year are visible. Each year has a plus sign beside it which can be clicked on to collapse all other years and expand that one. This is done to limit the size of the list and make it easier to find posts.
colapsable.js
This JavaScript file is used by the archive page to control collapsing and expanding sections. The file contains two functions. The first is called by clicking on the plus sign beside each year on the archive page and it expands a single section by looping through the list of year sections, collapsing them all and then expanding a given section by setting its display property to block. The second function is called by the first to collapse a section by setting its display property to none.
File not found: posts/comment.php This script is called by submitting the add comment form on the individual post pages. It starts out by creating a comments xml file if none exist and then opening it for writing. The script then adds the new comment to the file. The script finishes by sending me an email indicating an comment has been added and then redirects back to the original post.